package com.dabay.web.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.dabay.web.dao.ResultSupport;
import com.dabay.web.module.Arear_lishouyd;
import com.dabay.web.module.Arear_renli;
import com.dabay.web.module.Arear_shebaok;
import com.dabay.web.module.Arear_yanglao;
import com.dabay.web.module.Arear_yiliao;
import com.dabay.web.module.Arear_yiliaojg;
import com.dabay.web.module.Drugs;
import com.dabay.web.module.News;
import com.dabay.web.module.NewsDetail;
import com.dabay.web.service.Area_service;
import com.dabay.web.service.Constant;
import com.dabay.web.service.Drug_service;
import com.dabay.web.service.News_service;
import com.dabay.web.service.WeixinService;
import com.dabay.web.service.WxAccessTokenProperties;
import com.dabay.web.util.Helper;
import com.dabay.web.util.NbwxUtil;

@Controller
@RequestMapping("/nbwx/m")
public class WebController_home {
	@Autowired
	private News_service news_service;
	@Autowired
	private Area_service area_service;
	@Autowired
	private Drug_service drug_service;
	private static final Log log = LogFactory.getLog(WebController_home.class);
	private NbwxUtil nbwxUtil = new NbwxUtil();
	private WeixinService weixinService = new WeixinService();
	private WxAccessTokenProperties accessProperties=new WxAccessTokenProperties();
	/**
	 * 列表页面
	 * 
	 * @param i_tbr
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_liebiao")
	@ResponseBody
	public ModelAndView list_liebiao(@RequestParam(required = false) String item)
			throws Exception {
		ModelAndView mv = new ModelAndView();
		List<News> newsList = null;
		// 外埠新闻 125 本市新闻126 图片新闻127 县市区新闻1534 进人公告381 公务员招考382	
			try {
				if (item.equalsIgnoreCase("129")) {
					mv.addObject("item_content", "通知公告");
				} else if (item.equalsIgnoreCase("125")) {
					mv.addObject("item_content", "外埠要闻");
				} else if (item.equalsIgnoreCase("126")) {
					mv.addObject("item_content", "本市要闻");
				} else if (item.equalsIgnoreCase("127")) {
					mv.addObject("item_content", "图片新闻");
				} else if (item.equalsIgnoreCase("1534")) {
					mv.addObject("item_content", "县市区要闻");
				} else if (item.equalsIgnoreCase("381")) {
					mv.addObject("item_content", "事业单位招聘");
				} else if (item.equalsIgnoreCase("382")) {
					mv.addObject("item_content", "公务员招考");
				} else if (item.equalsIgnoreCase("166")) {
					mv.addObject("item_content", "就业培训");
				} else if (item.equalsIgnoreCase("170")) {
					mv.addObject("item_content", "社会保险");
				} else if (item.equalsIgnoreCase("172")) {
					mv.addObject("item_content", "人才人事");
				} else if (item.equalsIgnoreCase("1643")) {
					mv.addObject("item_content", "行政复议");
				} else if (item.equalsIgnoreCase("184")) {
					mv.addObject("item_content", "其他政策");
				} else if (item.equalsIgnoreCase("191")) {
					mv.addObject("item_content", "政策解读");
				}else if (item.equalsIgnoreCase("360")) {
					mv.addObject("item_content", "公务员招聘");
				}
				try {
					newsList = news_service.selectNewsByChannelid(item);
					if(newsList.size()>0){
						for (News news : newsList) {
							mv.addObject("docId", news.getDocid());
						}
					}	
				} catch (Exception e) {
					// TODO: handle exception
				}
							
				mv.addObject("newsList", newsList);
			} catch (Exception e) {
				e.printStackTrace();
			}
		mv.addObject("ITEM_THIS", item);
		mv.setViewName("/list_liebiao");
		return mv;
	}
	//
    @ResponseBody
    @RequestMapping({"/list_liebiaoMore"})
    public ResultSupport<Object> list_liebiaoMore(
    		@RequestParam(required = false) String item,
    		@RequestParam(required = false) Integer startNum){
	  log.info("receive load more request .....item is  "+item +"and startNum is "+startNum);
      System.out.println("receive load more request .....item is  "+item +"   and startNum is "+startNum);
      ResultSupport<Object> rs = new ResultSupport<Object>();
      List newsList =  new ArrayList();
      Map paramMap = new HashMap();
      paramMap.put("channelid", item);
      paramMap.put("startNum", startNum);
	  try {
		newsList = news_service.selectNewsByChannelid_FY(paramMap);
		rs.setSuccess(true);
		rs.setModel(newsList);
	  } catch (Exception e) {
		rs.setSuccess(false);
		rs.setMessage("操作失败！");;
		rs.setModel(newsList);
	  }
	  log.info("receive load more request end  ");
	  System.out.println("receive load more request end  ");
      return rs;
    }

	/**
	 * 列表详情页面
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_detail")
	@ResponseBody
	public ModelAndView list_detail(@RequestParam(required = false) String docid,HttpServletRequest request)
			throws Exception {
		String requestStr = new String(request.getQueryString().getBytes("iso-8859-1"),"utf-8");  
		log.info("新闻详情request参数"+requestStr);
		ModelAndView mv = new ModelAndView();
		NewsDetail newsDetail = null;
		List<String>  imagelist = new ArrayList<String>();
		try {
			newsDetail = news_service.selectNewsDetailByDocid(docid);
			//获取文章url
			String docUrl = newsDetail.getDocpuburl();
			docUrl = docUrl.substring(0, docUrl.lastIndexOf("/"));
			//获取图片路径
			String s = newsDetail.getDoccontent();
			String[] ss = s.split("\n");
			String content = "";
			String before = "";
			String after = "</br>";
			for (String string : ss) {
				content += before+string+after;
			}
			newsDetail.setDoccontent(content);
			String image =  newsDetail.getDocimage();
					List<String> tempList= new ArrayList<String>();  
					if (StringUtils.isNotEmpty(image)) {
						String[] strArray = image.split(";");
						for (String string : strArray) {
							tempList.add(string);
						}
					}			
			newsDetail.setImagelist(tempList);
			String previewListStr = "";
			String previewListStr2 = "";
			if(newsDetail.getImagelist().size()>0){
				for(int i=0;i<newsDetail.getImagelist().size();i++){
					String tempStr = newsDetail.getImagelist().get(i);
					if(i==newsDetail.getImagelist().size()-1){
						previewListStr+=tempStr;
						previewListStr2+="'"+tempStr+"'";
					}else{
						previewListStr+=tempStr+",";
						previewListStr2+="'"+tempStr+"',";
					}
				}
			}
			mv.addObject("previewListStr", previewListStr);
			mv.addObject("previewListStr2", previewListStr2);
			//获取附件地址
			String appfile = newsDetail.getAppfile();
			if (StringUtils.isNotEmpty(appfile)) {
				newsDetail.setAppfile(docUrl+"/"+appfile);				
			}
			//微信逻辑处理   先比较上次票据获取时间和两小时 比 实)之内就不必重新获取
			String update_time = accessProperties.getProertiesValue("update_time");
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
    	    Date date = sdf.parse(update_time); 
    	    long updateTime = date.getTime();            
    	    long currentTime = System.currentTimeMillis();
    	    //1个小时5 分钟即为 6900000ms
    	    if((currentTime - updateTime)>6900000 ){
    	    	//超过两小时重新获取
    	    	 String access_token = weixinService.getAccessTokenStr(Constant.APP_ID_NB,Constant.SECRET_NB);
    			 String jsapi_ticket = weixinService.getJsapi_ticketStr(access_token);
    			 String noncestr = new Helper().getRandomString(16);
    			 String timestampStr = System.currentTimeMillis()+"";
    			 String url="http://app.nbhrss.gov.cn/nbrs_web_weixin/nbwx/m/list_detail?"+requestStr;
    			 String signature = "jsapi_ticket="+jsapi_ticket;
    			  		 signature+="&noncestr="+noncestr;
    			  		 signature+="&timestamp="+timestampStr;
    			  		 signature+="&url="+url;
    			String signatureNew = DigestUtils.shaHex(signature);
    			String wx_url="http://app.nbhrss.gov.cn/nbrs_web_weixin/nbwx/m/list_detail?docid="+docid;
    			mv.addObject("wx_appId", Constant.APP_ID_NB);
    			mv.addObject("wx_timestamp", timestampStr);
    			mv.addObject("wx_nonceStr", noncestr);
    			mv.addObject("wx_signature", signatureNew);  
    			mv.addObject("wx_url", wx_url);
    			//配置文件记录信息重写
    	    	String dateStr = sdf.format(new Date());
    	    	accessProperties.setProperties("jsapi_ticket", jsapi_ticket); 
    	    	accessProperties.setProperties("update_time", dateStr); 
    	    	accessProperties.setProperties("noncestr", noncestr); 
    	    	accessProperties.setProperties("timestamp", timestampStr); 
    	    }else{
    	    	//低于两小时直接读取 不再获取
    			 String jsapi_ticket = accessProperties.getProertiesValue("jsapi_ticket");
    			 String noncestr = accessProperties.getProertiesValue("noncestr");;
    			 String timestampStr = accessProperties.getProertiesValue("timestamp");
    			 String url="http://app.nbhrss.gov.cn/nbrs_web_weixin/nbwx/m/list_detail?"+requestStr;
    			 String signature = "jsapi_ticket="+jsapi_ticket;
    			  		 signature+="&noncestr="+noncestr;
    			  		 signature+="&timestamp="+timestampStr;
    			  		 signature+="&url="+url;
    			String signatureNew = DigestUtils.shaHex(signature);
    			String wx_url="http://app.nbhrss.gov.cn/nbrs_web_weixin/nbwx/m/list_detail?docid="+docid;
    			mv.addObject("wx_appId", Constant.APP_ID_NB);
    			mv.addObject("wx_timestamp", timestampStr);
    			mv.addObject("wx_nonceStr", noncestr);
    			mv.addObject("wx_signature", signatureNew);
    			mv.addObject("wx_url", wx_url);
    	    }
			mv.addObject("newsDetail", newsDetail);
		} catch (Exception e) {
			e.printStackTrace();
		}
		mv.setViewName("/list_detail");
		return mv;
	}
	
	/**
	 * 政务动态按钮页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_zhengwudongtai")
	@ResponseBody
	public ModelAndView list_zhengwudongtai()
			throws Exception {
		ModelAndView mv = new ModelAndView();
		// 外埠新闻 125 本市新闻126 图片新闻127 县市区新闻1534
		List<News> newsList = null;
		List<News> newsList_wbxw = new ArrayList<News>();
		List<News> newsList_bsxw = new ArrayList<News>();
		List<News> newsList_tpxw = new ArrayList<News>();
		List<News> newsList_xsqxw = new ArrayList<News>();
		try {
			newsList = news_service.selectNewsLimit_zwdt();
			for (News news : newsList) {
				String image =  news.getDocimage();
				if (StringUtils.isNotEmpty(image)) {
					String[] strArray = image.split(";");
					if(strArray.length>0){
						//news.setDocimage(strArray[0]);
						//首页获取的都是本地图片
						news.setDocimage(nbwxUtil.getLoacalFilePath(strArray[0]));
					}
				}
				if(("125").equals(news.getChannelid())){
					newsList_wbxw.add(news);
				}else  if(("126").equals(news.getChannelid())){
					newsList_bsxw.add(news);
				}else  if(("127").equals(news.getChannelid())){
					newsList_tpxw.add(news);
				}else  if(("1534").equals(news.getChannelid())){
					newsList_xsqxw.add(news);
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		mv.addObject("newsList_wbxw", newsList_wbxw);
		mv.addObject("newsList_bsxw", newsList_bsxw);
		mv.addObject("newsList_tpxw", newsList_tpxw);
		mv.addObject("newsList_xsqxw", newsList_xsqxw);
		mv.setViewName("/list_zhengwudongtai");
		return mv;
	}
	
	/**
	 * 服务机构 一级  页面
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_fuwujigou_home")
	@ResponseBody
	public ModelAndView list_fuwujigou_home()
			throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/list_fuwujigou_home");
		return mv;
	}

	/**
	 *  服务机构 二级  页面
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_jigouclass_home")
	@ResponseBody
	public ModelAndView list_jigouclass_home(HttpServletRequest request,
			@RequestParam(required = false) int type,
			@RequestParam(required = false) String name) throws Exception {
		request.setCharacterEncoding("UTF-8");
		ModelAndView mv = new ModelAndView();
		try {
			switch (type) {
			case 1:
				// 人力资源和社会保障局	
				List<Arear_renli> arear_renli_list = null;
				try {
					arear_renli_list = area_service.selectArear_renli_list();
					mv.addObject("arear_renli_list", arear_renli_list);
					mv.addObject("types", type);
					mv.addObject("item", "人力资源和社会保障局");
				} catch (Exception e) {
					e.printStackTrace();
				}
				mv.setViewName("/list_jigouclass1_home");// 人力资源和社会保障局
				break;
			case 2:
				// 养老保险经办机构
				List<Arear_yanglao> arear_yanglao_list = null;
					try {
						arear_yanglao_list = area_service.selectArear_yanglao_list(name);
						mv.addObject("arear_yanglao_list", arear_yanglao_list);
						mv.addObject("types", type);
						mv.addObject("item", "养老保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				mv.setViewName("/list_jigouclass2_home_list");// 养老保险经办机构
				break;
			case 3:
				// 医疗保险经办机构
				List<Arear_yiliao> arear_yiliao_list = null;
					try {
						arear_yiliao_list = area_service.selectArear_yiliao_list(name);
						mv.addObject("arear_yiliao_list", arear_yiliao_list);
						mv.addObject("types", type);
						mv.addObject("item", "医疗保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				mv.setViewName("/list_jigouclass2_home_list");// 医疗保险经办机构
				break;
			case 4:
				// 社保卡服务机构
				List<Arear_shebaok> arear_shebaok_list = null;
					try {
						arear_shebaok_list = area_service.selectArear_shebaok_list(name);
						mv.addObject("arear_shebaok_list", arear_shebaok_list);
						mv.addObject("types", type);
						mv.addObject("item", "社保卡服务机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				mv.setViewName("/list_jigouclass2_home_list");// 社保卡服务机构
				break;
			case 5:
				//市区城镇医保定点医疗机构
				List<Arear_yiliaojg> arear_yiliaojg_list = null;
					try {
						arear_yiliaojg_list = area_service.selectArear_yiliaojgk_list(name);
						mv.addObject("arear_yiliaojg_list", arear_yiliaojg_list);
						mv.addObject("types", type);
						mv.addObject("item", "市区城镇医保定点医疗机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				mv.setViewName("/list_dingdian");// 市区城镇医保定点医疗机构
				break;
			case 6:
				//市区城镇医保定点零售药店
				List<Arear_lishouyd> arear_lishouyd_list = null;
					try {
						arear_lishouyd_list = area_service.selectArear_lishouyd_list(name);
						mv.addObject("arear_lishouyd_list", arear_lishouyd_list);
						mv.addObject("types", type);
						mv.addObject("item", "医疗保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				mv.setViewName("/list_dingdian");// 市区城镇医保定点医疗机构
				break;
			default:
				break;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return mv;
	}

    @ResponseBody
    @RequestMapping({"/list_dingdianMore"})
    public ResultSupport<Object> list_dingdianMore(
    		@RequestParam(required = false) String type,
    		@RequestParam(required = false) Integer startNum,
    		@RequestParam(required = false) String name) throws  Exception {
      ResultSupport<Object> rs = new ResultSupport<Object>();
      if(type.equals("5")){
    	  List<Arear_yiliaojg> arear_yiliaojg_list = new ArrayList<Arear_yiliaojg>();
          if(name==null ){
        	  name="";
          }
          name = nbwxUtil.encodeCHNStr(name);
          Map paramMap = new HashMap();
          paramMap.put("startNum", startNum);
          paramMap.put("name", name);
    	  try {
    		arear_yiliaojg_list = area_service.selectArear_yiliaojgk_listFY(paramMap);
    		rs.setSuccess(true);
    		rs.setModel(arear_yiliaojg_list);
    	  } catch (Exception e) {
    		rs.setSuccess(false);
    		rs.setMessage("操作失败！");;
    		rs.setModel(arear_yiliaojg_list);
    	  }
     }
      if(type.equals("6")){
    	  List<Arear_lishouyd> arear_lishouyd_list = new ArrayList<Arear_lishouyd>();;
          if(name==null ){
        	  name="";
          }
          name = nbwxUtil.encodeCHNStr(name);
          Map paramMap = new HashMap();
          paramMap.put("startNum", startNum);
          paramMap.put("name", name);
    	  try {
    		arear_lishouyd_list = area_service.selectArear_lishouyd_listFY(paramMap);
    		rs.setSuccess(true);
    		rs.setModel(arear_lishouyd_list);
    	  } catch (Exception e) {
    		rs.setSuccess(false);
    		rs.setMessage("操作失败！");;
    		rs.setModel(arear_lishouyd_list);
    	  }
     }
      return rs;
    }	

	/**
	 * 定点机构详情页面(带检索页面)
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_jigouclass_home_detail")
	@ResponseBody
	public ModelAndView list_jigouclass_home_detail(@RequestParam(required = false) int type,
			@RequestParam(required = false) int detail_id) throws Exception {
		log.info("--------进入定点机构详情页面-------------");		
		ModelAndView mv = new ModelAndView();		
		try {
			switch (type) {
			case 2:
				// 养老保险经办机构
				log.info("--------执行 养老保险经办机构 查询操作-------------");
				Arear_yanglao arear_yanglao = null;
					try {
						arear_yanglao = area_service.selectArear_yanglaoById(detail_id);
						mv.addObject("arear_yanglao", arear_yanglao);						
						mv.addObject("types", type);
						mv.addObject("item", "养老保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				break;
			case 3:
				// 医疗保险经办机构
				log.info("--------执行 医疗保险经办机构 查询操作-------------");
				Arear_yiliao arear_yiliao = null;
					try {
						arear_yiliao = area_service.selectArear_yiliaoById(detail_id);
						mv.addObject("arear_yiliao", arear_yiliao);						
						mv.addObject("types", type);
						mv.addObject("item", "医疗保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				break;
			case 4:
				// 社保卡服务机构
				log.info("--------执行 社保卡服务机构 查询操作-------------");
				Arear_shebaok arear_shebaok = null;
					try {
						arear_shebaok = area_service.selectArear_shebaokById(detail_id);
						mv.addObject("arear_shebaok", arear_shebaok);						
						mv.addObject("types", type);
						mv.addObject("item", "医疗保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				break;
			case 5:
				// 市区城镇医保定点医疗机构
				log.info("--------执行 市区城镇医保定点医疗机构 查询操作-------------");
				Arear_yiliaojg arear_yiliaojg = null;
					try {
						arear_yiliaojg = area_service.selectArear_yiliaojgById(detail_id);
						mv.addObject("arear_yiliaojg", arear_yiliaojg);						
						mv.addObject("types", type);
						mv.addObject("item", "医疗保险经办机构");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				break;
			case 6:
				// 市区城镇医保定点零售药店
				log.info("--------执行市区城镇医保定点零售药店查询操作-------------");
				Arear_lishouyd arear_lishouyd = null;
					try {
						arear_lishouyd = area_service.selectArear_lishouydById(detail_id);
						mv.addObject("arear_lishouyd", arear_lishouyd);						
						mv.addObject("types", type);
						mv.addObject("item", "市区城镇医保定点零售药店");
					} catch (Exception e) {
						e.printStackTrace();
					}
				
				break;
			
			default:
				break;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		mv.setViewName("/list_jigouclass_home_detail");
		return mv;
	}
	
	/**
	 * 政策法规 一级  页面
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_policy")
	@ResponseBody
	public ModelAndView list_policy(@RequestParam(required = false) String item)
			throws Exception {
		ModelAndView mv = new ModelAndView();
		List<News> newsList_jypx = null;
		try {
			try {
				newsList_jypx = news_service.selectNewsByChannelid("166");
			} catch (Exception e) {
				// TODO: handle exception
			}
			mv.addObject("newsList_jypx", newsList_jypx);
		} catch (Exception e) {
			e.printStackTrace();
		}

		mv.setViewName("/list_policy");
		return mv;
	}

	/**
	 * 医保药品目录 一级 页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_drugs")
	@ResponseBody
	public ModelAndView list_drugs(HttpServletRequest request,@RequestParam(required = false) String name,
			@RequestParam(required = false) Integer startNum) throws Exception {
		request.setCharacterEncoding("UTF-8");
		if(startNum==null || startNum<0){
			startNum=1;
		}
		if(name==null ||"null".equals(name)){
			name="";
		}
		name = nbwxUtil.encodeCHNStr(name);
		 Map paramMap = new HashMap();
	     paramMap.put("name", name);
	     paramMap.put("startNum", startNum);
		ModelAndView mv = new ModelAndView();
		List<Drugs> drugsList = null;
		try {
			drugsList = drug_service.selectDrugsList(paramMap);
			mv.addObject("drugsList", drugsList);
		} catch (Exception e) {
			// TODO: handle exception
		}
		mv.setViewName("/list_drugs");
		return mv;
	}
	
	
	@RequestMapping(value = "/list_drugs_search")
	@ResponseBody
	public ModelAndView list_drugs_search(HttpServletRequest request,@RequestParam(required = false) String name) throws Exception {
		request.setCharacterEncoding("UTF-8");
		name = nbwxUtil.encodeCHNStr(name);
		ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:/nbwx/m/list_drugs");
        mv.addObject("name",name);
		return mv;
	}
	
	//=========
	@ResponseBody
	@RequestMapping(value = "/search_drugs")
	public ResultSupport<?> search_drugs(HttpServletRequest request,@RequestParam(required = false) String name,
			@RequestParam(required = false) Integer startNum) throws Exception{
		request.setCharacterEncoding("UTF-8");
		name = nbwxUtil.encodeCHNStr(name);
		if(startNum==null || startNum<0){
			startNum=1;
		}
		if(name==null ||"null".equals(name)){
			name="";
		}
		 Map paramMap = new HashMap();
	     paramMap.put("name", name);
	     paramMap.put("startNum", startNum);
		ResultSupport result = new ResultSupport();
		ModelAndView mv = new ModelAndView();
		List<Drugs> drugsList = null;
		try {
			drugsList = drug_service.selectDrugsList(paramMap);
			result.setResultCode(0);
			result.setModel(drugsList);
			result.setSuccess(true);
		} catch (Exception e) {
			result.setResultCode(1);
			result.setSuccess(true);
		}
		return result;
	}
	
	/**
	 * 医保药品目录 二级 页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_drugs_detail")
	@ResponseBody
	public ModelAndView list_drugs_detail(int drugs_id) throws Exception {
		ModelAndView mv = new ModelAndView();
		Drugs drugs = null;
		mv.addObject("item", "医疗保险药品目录");
		try {
			drugs = drug_service.selectDrugsById(drugs_id);
			mv.addObject("drugs", drugs);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		mv.setViewName("/list_drugs_detail");
		return mv;
	}
	
	
	/**
	 * 医保药品目录 二级 页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/list_test")
	@ResponseBody
	public ModelAndView list_test() throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/list_test");
		return mv;
	}
	//
    @ResponseBody
    @RequestMapping({"/listTestMore"})
    public ResultSupport<Object> listTestMore(
    		@RequestParam(required = false) String item){
      log.info("receive item .....");
      System.out.println("receive item date.....");
      ResultSupport<Object> rs = new ResultSupport<Object>();
      rs.setSuccess(true);
      log.info("ok....");
      System.out.println("ok....");
      return rs;
    }
}